package com.sinosoft.quick;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class QuickManagerImp implements QuickManager {

	QuickDao qDao;
	
	@Autowired
	public void setQuickDao(QuickDao dao)
	{
		this.qDao = dao;
	}
	
	public int getQuickCount(Quick quick) {
		String satelliteid = quick.getSatelliteid();
		String sensorid = quick.getSensorid();
		StringBuffer hql = new StringBuffer("select count(*) from zywx_image_quick o where 1=1");
		hql.append(sensorid!=null&&!sensorid.isEmpty()?" and sensorid like '%"+sensorid.trim()+"%'":"");
		hql.append(satelliteid != null && !satelliteid.isEmpty()?" and satelliteid='%"+satelliteid+"%'":"");
		return qDao.getQuickCount(hql.toString());
	}

	public List<Quick> getQuickListByPage(Quick quick, int first, int pagesize) {
		return qDao.getQuickListByPage(quick, first, pagesize);
	}

	public Quick getQuickById(int id)
	{
		String sql = "from Quick where datasetid="+id;
		return qDao.getQuickById(sql);
	}
	
	public void deleteQuick(Quick quick)
	{
		qDao.deleteQuick(quick);
	}
}
